<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<div id="assitdbGrid"></div>
<div id="assitdbToolbar">
	<div>
		<a href="#" class="easyui-linkbutton" onclick="assitdb.toolbar.remove();" data-options="
		iconCls:'icon-remove',
		plain:true">
			删除
		</a>
		<a href="#" class="easyui-linkbutton" onclick="assitdb.toolbar.redo();" data-options="
		iconCls:'icon-redo',
		plain:true">
			取消
		</a>
	</div>
</div>

<script>	
	var assitdb = {
		init : function() {
			assitdb.assitdbGrid = $('#assitdbGrid');
			assitdb.assitdbUpdateForm = $('#assitdbUpdateForm');
			assitdb.assitdbUpdateDialog = $('#assitdbUpdateDialog');
			
			assitdb.assitdbGrid.datagrid({
			    url: '<%=request.getContextPath()%>/AssitdbServlet?command=listAssitdb',
			    fixed: true,
			    fitColumns: true,
			    striped: true,
			    rownumbers: true,
			    pagination: true,
			    pageSize: 50,
			    pageList: [10, 20, 30, 40, 50],
			    pageNumber: 1,
			    sortName: 'bakTime',
			    sortOrder: 'desc',
			    toolbar: '#assitdbToolbar',
			    columns:[[
					{field:'id', checkbox: true},
					{field:'bakUrl', title:'存放文件', width:100, align:'center'},
					{field:'bakTime', title:'备份时间', width:100, align:'center', sortable: true},
					{field:'bakMemo', title:'备份备注', width:100, align:'center'},
					{field:'user__name', title:'操作者', width:50, align:'center'},
					]],
				onDblClickRow: function(rowIndex, rowData) {
					assitdb.toolbar.showUpdateDialog(rowData.id);
				}
			});
		},
		toolbar: {
			showAddDialog: function() {
				assitdb.assitdbAddDialog.dialog('open');
			},
			hiddenAddDialog: function() {
				assitdb.assitdbAddDialog.dialog('close');
				assitdb.toolbar.resetAddForm();
			},
			resetAddForm: function() {
				assitdb.assitdbAddForm.form('reset');
			},
			remove: function() {
				var row = assitdb.assitdbGrid.datagrid('getSelections');
				if (row.length > 0) {
					var ids = [];
					$.each(row, function(i, v) {
						ids.push(v.id);
					});
					$.post('<%=request.getContextPath()%>/AssitdbServlet?command=deleteAssitdb', {ids: ids.join(',')}, function(data) {
						if (data == 1) {
							$.messager.show({
								title: '系统提示',
								msg: '删除成功！',
								timeout: 3000,
								showType: 'slide'
							});
							assitdb.assitdbGrid.datagrid('reload');
						} else {
							$.messager.alert('系统提示', '删除失败！', 'error')
						}
						$.messager.progress('close');
					});
				} else {
					$.messager.show({
						title: '系统提示',
						msg: '请选择数据进行删除！',
						timeout: 3000,
						showType: 'slide'
					});	
				}
			},
			redo: function() {
				assitdb.assitdbGrid.datagrid('unselectAll');
			},
		},
	};
	
	$(function(){
		assitdb.init();
	});
</script>
